//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <string.h>
#include <wchar.h>

wchar_t * __cdecl wcschr(const wchar_t * p, wint_t c)
{
/*
    register wchar_t *__res;
#if !defined(_arm)
    int d0, d1;
    asm __volatile__(
        "movl %6,%%eax\n\t"
        "repne\n\t"
        "scasw\n\t"
        "subl $2, %%edi\n\t"
        "xorl %%eax, %%eax\n\t"
        "movl %%edi, %%eax\n"
        :"=a" (__res), "=&c" (d0), "=&D" (d1)
        :"0" (0), "1" (0xffffffff), "2" (string), "g" (c)
        :"dx");
#else
    for (; *string; ++string) {
        if (*string == c)
            return((wchar_t *)string);
        else if (*(string+1) == c)
            return((wchar_t *)(string+1));
    }
    return (wchar_t *)(NULL);
#endif

    return __res;
*/
    if (!p)
        return (NULL);

    for (; *p; p++) {
        if (*p == (wchar_t)c) {
            return ((wchar_t *)p);
        }
    }

    if (*p == (wchar_t)c) {
        return ((wchar_t *)p);
    }

    return (NULL);
}
